package org.dsbackend.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CharUtils {
    public static boolean hasIllegalChar(String ... strs) {
        String regEx =
            "[ _`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]|\n|\r|\t";
        Pattern p = Pattern.compile(regEx);
        for(String str:strs)
        {
            Matcher m = p.matcher(str);
            if(m.find())
                return true;
        }
        return false;
    }

    public static boolean checkEmail(String emaile){
        String RULE_EMAIL = "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$";
        Pattern p = Pattern.compile(RULE_EMAIL);
        Matcher m = p.matcher(emaile);
        return m.matches();
    }
}
